function valueAtBit(num, bit) {
    return (num >> (bit - 1)) & 1;
}

function base10(str) {
    return parseInt(str, 2);
}

function convertToBinary(num) {
    let str = num.toString(2);
    while (str.length < 8) {
        str = "0" + str;
    }

    return str;
}

function convertToBinary(num) {
    //转换为2进制格式
    let s = num.toString(2);
    //获得2进制数长度
    const l = s.length;
    if (l < 8) {
        //声明一个字符串用于补满0
        const s1 = "0000000";
        const s2 = s1.slice(0, 8 - l);
        s = s2 + s;
    }
    return s;
}